﻿using HR.Filters;
using HR.IServices.PengIService;
using HR.Models.PengModels;
using Microsoft.AspNetCore.Mvc;

namespace HR.Controllers
{
    public class MianSController : Controller
    {
        private readonly IMianShiService mianShiServices;

        public MianSController(IMianShiService  MianShiServices) {
            mianShiServices = MianShiServices;
        }

        [TypeFilter(typeof(RoleFilterAttribute))]
        public IActionResult ShaiX() {
            return View();
        }
        [TypeFilter(typeof(RoleFilterAttribute))]
        public IActionResult Index()
        {
            return View();
        }
        [TypeFilter(typeof(RoleFilterAttribute))]
        public IActionResult LuYon() {
            return View();
        }
        [HttpGet]
        public async Task<IActionResult> LianChaer() {
            List<MsJlLianCha> list = await mianShiServices.LianChaer();
            return Json(list);
        }

        [HttpPost]
        public async Task<IActionResult> MianSAdd([FromBody] MianShi ms) {
            int result = await mianShiServices.MianShiAdd(ms);
            if (result > 0)
            {
                return Content(result.ToString());
            }
            else {
                return View(result);
            }
        }
        [HttpGet]
        public async Task<IActionResult> ZtSel() {
            List<MianShi> list = await mianShiServices.ZtSel();
            return Json(list);
        }
        [HttpGet]
        public async Task<IActionResult> MsJlSel()
        {
            List<MsJlLianCha> list = await mianShiServices.LiangBSel();
            return Json(list);

        }
        [HttpGet]
        public async Task<IActionResult> MianSFind(int resume_id)
        {
            MianShi? ms = await mianShiServices.MianSFind(resume_id);
            return Json(ms);
        }
    }
}
